Xi-Language Reference: General Functions
- eof (End of File)
- istream (Opens a file for reading)
- listvariables (prints out all defined variables)
- ostream (Opens a file for writing)
- print (Prints one or more expressions)
- printf (Formated output of one or more expressions)
- sprintf (Formated output in a string)
Parameters
eof ( istream )
Types: istream istream
Return
int (-1, 0, > 0)
Description
The Function eof returns nonzero when the end of a file has been reached.
Otherwise it returns zero. Minus one indicates an error.
Example
( 1)>s=istream("bla.out");
( 2)>print(eof(s));
<int> 0
See also
istream
Parameters
istream ( name, ascii = 0, bin = 0, fortran = 0 )
Types: name string
ascii int
bin int
fortran int
Return
istream (Containing the intput stream)
Description
The istream opens a file name for reading if it exists.
The flags ascii, bin and fortran have the same
meaning as the corresponding flags of the ostream function.
Example
( 1)>s=istream("bla.out");
( 2)>double arr[5,5];
( 3)>s >> arr;
( 4)>delete s;
( 5)>print(arr);
<dblarr>
0 1 2 3 4
5 6 7 8 9
10 11 12 13 14
15 16 17 18 19
20 21 22 23 24
See also
eof,
ostream
Parameters
listvariables ( )
Return
-1
Description
The function listvariables prints out all defined variables.
Example
>double a=0, b=2;
>char s;
>listvaribles();
a : <double>0
b : <double>2
s : Not defined yet
0
Parameters
ostream ( name, ascii = 0, bin = 0, fortran = 0 )
Types: name string
ascii int
bin int
fortran int
Return
ostream (Containing the output stream)
Description
The ostream opens a file name for writing, if the file exists it
will be erased, so be causious with this function. The ascii flag
indicates that the file should be written in a readable format, i.e. numbers
will be explicitly written and arrays are given in tabular order - of cause
this costs a lot of memory. The bin indicates that the file should
be written in binary (non-readable) format which is a lot faster and costs
less memory than the ascii-format. The fortran is usefull if you
want to write output that could be read by a fortran programm with the
option unformatted. This format is not readable too.
Example
( 1)>s=ostream("bla.out");
( 2)>arr=dincarr(5,5);
( 3)>s << arr;
( 4)>delete s;
( 5)>$ cat bla.out
0 1 2 3 4
5 6 7 8 9
10 11 12 13 14
15 16 17 18 19
20 21 22 23 24
See also
istream
Parameters
print ( arg... )
Types: arg... Any
Return
-1
Description
The print function simply prints the result of an arbitrary number
of expressions. In other words: First arg0 will be calculated then
arg1 and so on. print explicitly prints the type of the results.
Example
( 1)>print(5+4,dincarr(10),"blabla");
<int> 9
<dblarr>
0 1 2 3 4 5
6 7 8 9
<string> "blabla"
Parameters
printf ( format, arg... )
Types: format string
arg... Any
Return
-1
Description
The printf acts in the same way as the corresponding C function.
For detailed information of the format-string's structure refer to
a C-introduction.
Example
( 1)>printf("The Value of %s is %g\n","bla",5+4);
The Value of bla is 9
Parameters
sprintf ( format, arg... )
Types: format string
arg... Any
Return
string (containing the output)
Description
The sprintf acts in the same way as the printf with the
only difference that the output is not printed on the console but is stored
in a string. Note that the Xi version of sprintf has a slightly different
calling sceem than the coresponding C function.
Example
( 1)>a=sprintf("The Value of %s is %g","bla",5+4);
( 2)>print(a);
<string> "The Value of bla is 9"
See also
printf
© 1995 by Bodo Junglas, Klaus Spanderen and Fabian Weis
- Last revised: Wed Jun 19 16:58:32 1996